<template>
  <PageMain>
    <template #header></template>
    <template #body>
      <div
        class="resource-view-1-box w-full h-full overflow-hidden box-border flex justify-start items-center flex-col"
      >
        <div
          class="content w-full h-[calc(100%_-_64px)] box-border p-[20px_24px] overflow-hidden overflow-y-auto"
        >
          <div
            class="w-full h-[56px] p-[16px_0] overflow-hidden box-border flex justify-start items-start"
            style="font-family: Microsoft YaHei; font-size: 16px; font-weight: bold; color: #394d73"
          >
            基础信息
          </div>
          <div class="info w-full h-auto p-[20px] box-border bg-[#f7f9fc] rounded-[8px]">
            <a-row>
              <a-col :span="8">
                <div class="content">
                  <span class="icon">项目编号 :</span>
                  <span class="text">{{ formInline.code }}</span>
                </div>
              </a-col>
              <a-col :span="8">
                <div class="content">
                  <span class="icon">项目名称 :</span>
                  <span class="text">{{ formInline.name }}</span>
                </div>
              </a-col>
              <a-col :span="8">
                <div class="content">
                  <span class="icon">项目经理 :</span>
                  <span class="text">{{ formInline.manager }}</span>
                </div>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="8">
                <div class="content">
                  <span class="icon">项目进度 :</span>
                  <span class="text">
                    <span
                      v-if="formInline.status == '完成'"
                      class="circle-point border-[#34C94F]"
                    ></span>
                    <span
                      v-else-if="formInline.status == '停滞'"
                      class="circle-point border-[#FF4C38]"
                    ></span>
                    <span
                      v-else-if="formInline.status == '进行中'"
                      class="circle-point border-[#FF4C38]"
                    ></span>
                    {{ formInline.status }}</span
                  >
                </div>
              </a-col>
              <a-col :span="8">
                <div class="content">
                  <span class="icon">项目预算 :</span>
                  <span class="text">{{ formInline.budget }}</span>
                </div>
              </a-col>
              <a-col :span="8">
                <div class="content">
                  <span class="icon">实际花费 :</span>
                  <span class="text">{{ formInline.actual }}</span>
                </div>
              </a-col>
            </a-row>
            <a-row>
              <a-col :span="8">
                <div class="content">
                  <span class="icon">起始日期 :</span>
                  <span class="text"
                    >{{ formInline.begin_time }} <span v-if="formInline.begin_time">至</span>
                    {{ formInline.end_time }}</span
                  >
                </div>
              </a-col>
              <a-col :span="12">
                <div class="content">
                  <span class="icon">项目描述 :</span>
                  <span class="text">{{ formInline.describe }}</span>
                </div>
              </a-col>
            </a-row>
          </div>
          <div
            class="w-full h-[56px] p-[16px_0] overflow-hidden box-border flex justify-start items-start"
            style="font-family: Microsoft YaHei; font-size: 16px; font-weight: bold; color: #394d73"
          >
            人员信息
          </div>
          <CommonTable
            :showPagination="false"
            :columnsData="showDetailTableData"
            :tableData="formInline.project_persons"
          />
        </div>
      </div>
    </template>
  </PageMain>
</template>

<script lang="ts" setup>
import { onMounted, reactive } from 'vue';
import { showDetailTableData } from './values';
import { useRoute } from 'vue-router';
import { getDetail } from '@/api/assetManagement/resource_project/index';

const route = useRoute();
// 表单数据
const formInline = reactive({
  actual: '', //实际花费
  begin_time: '', //开始时间
  budget: '', //预算
  code: '', //项目编号
  describe: '', //项目描述
  end_time: '', //结束时间
  manager: '', //项目经理
  name: '', //项目名称
  project_persons: [], //项目人员
  status: '' //状态
});

/**
 * @method checkDetail 获取详情
 */
const checkDetail = async () => {
  const { data } = await getDetail(route.query.id as string);
  Object.keys(data).forEach((key) => {
    if (formInline.hasOwnProperty(key)) {
      formInline[key] = data[key];
    }
  });
};
onMounted(() => {
  checkDetail();
});
</script>

<style lang="less" scoped>
.MainBox {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}
.TabPaneClass {
  padding: 0 30px;
}
.content {
  margin-bottom: 33px;
  font-size: 14px;
  font-family: MicrosoftYaHei;
  color: #465a80;

  .icon {
    color: #a3b0cc;
    font-family: Microsoft YaHei;
    font-size: 14px;
    font-weight: normal;
  }
  .text {
    padding-left: 16px;
    color: #465a80;
    font-family: Microsoft YaHei;
    font-size: 14px;
    font-weight: normal;
  }
}
.footer {
  border-top: 1px solid #ebf0fa;
  width: 100%;
  padding: 0 20px;
  display: flex;
  justify-content: flex-end;
  height: 50px;
  align-items: center;
}
.circle-point {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border-width: 2px;
}
</style>
